package com.changli03._list.exer1;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Scanner;

public class StudentTest {
    public static void main(String[] args) {
        Collection list = new ArrayList();
        Scanner sc = new Scanner(System.in);
        boolean flag = true;
        System.out.println("请录入学生的信息");
        while(flag){
            int  isContinue = 1;
            System.out.println("1:继续录入，0:结束录入：");
            isContinue = sc.nextInt();
            if(isContinue==1){
                flag = true;
            }
            else if(isContinue==0){
                flag = false;
            }
            String name = "";
            int age = 0;
            if(flag){
                System.out.print("请输入学生的姓名：");
                name = sc.next();
                System.out.print("请输入学生的年龄：");
                age = sc.nextInt();
                Student s = new Student(name,age);
                list.add(s);
            }
            else {
                break;
            }
        }
        sc.close();
        System.out.println("遍历学生信息：");
        for(Object o : list){
            System.out.println(o);
        }
    }
}
